import React, { useEffect, useState } from 'react';

function Welcome(props) {
    useEffect(() => {
        document.title = `hi,${props.name}`;
    });
    return <h1 onClick={props.onClick} >Hello, {props.name}</h1>;
}

function Hook() {

    const [name, setName] = useState('wmg')
    const [sex, setSex] = useState('男')

    return <div>
        <button onClick={() => { setSex('女') }}>点我</button>
        <div>{sex}</div>
        <Welcome name={name} sex={sex} onClick={() => setName(new Date().getTime())} />
    </div>

}

export default Hook;